<?xml version="1.0" encoding='UTF-8'?>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Vector" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="com.teragadgets.android.comics.appengine.WebComic" %>
<%@ page import="com.teragadgets.android.comics.appengine.PMF" %>

<webcomics>

<%
	List<WebComic> webComics = new Vector<WebComic>();
    PersistenceManager pm = PMF.get().getPersistenceManager();
    String query = "select from " + WebComic.class.getName();
    try {
    	String[] ids = request.getParameter("ids").split(",");
    	query += " where id == idParam parameters Long idParam";
    	query += " order by name";
    	for(String id : ids)
    		webComics.addAll((List<WebComic>) pm.newQuery(query).execute(Long.parseLong(id)));
    } catch(Exception e) {
    	query += " order by name";
     	webComics.addAll((List<WebComic>) pm.newQuery(query).execute());
    }
    
    for (WebComic c : webComics) {
%>
		<webcomic favicon="<%= c.getFavicon() %>" name="<%= c.getName() %>" url="<%= c.getURL() %>" id="<%= c.getID() %>" latest="<%= c.getLatestComic() %>" />
<%
    }
    pm.close();
%>

</webcomics>